﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;

namespace DeployGames.TweenEngine.TestBed.wpf.acessor
{
    public class ButtonAcessor : IBaseTweenAcessor
    {
        public const int X = 0;
        public const int Y = 1;
        public const int XY = 2;

        public int getValues(IBaseAcessor target, int tweenType, float[] returnValues)
        {
            AcessorButton bt = (target as AcessorButton);
            if (bt != null)
            {
                switch (tweenType)
                {
                    case X:
                        returnValues[0] = (float)Canvas.GetLeft(bt);
                        return 1;
                    case Y:
                        returnValues[0] = (float)Canvas.GetTop(bt);
                        return 1;
                    case XY:
                        returnValues[0] = (float)Canvas.GetLeft(bt);
                        returnValues[1] = (float)Canvas.GetTop(bt);
                        return 2;
                }
            }
            return 0;
        }

        public void setValues(IBaseAcessor target, int tweenType, float[] newValues)
        {
            AcessorButton bt = (target as AcessorButton);
            if (bt != null)
            {
                switch (tweenType)
                {
                    case X:
                        Canvas.SetLeft(bt, newValues[0]);
                        break;
                    case Y:
                        Canvas.SetTop(bt, newValues[0]);
                        break;
                    case XY:
                        Canvas.SetLeft(bt, newValues[0]);
                        Canvas.SetTop(bt, newValues[1]);
                        break;
                }
            }
        }
    }
}
